package code 
{
	import flash.utils.describeType;
	import flash.utils.getQualifiedClassName;
	/**
	 * ...
	 * @author XXL
	 */
	public class CheckClass 
	{
		
		public function CheckClass() 
		{
			
		}
		
		/**
		 * 速度最快，但仅支持类，或者同一个接口比较，无法支持不同接口，接口/类混搭比较的情况
		 * @param	a
		 * @param	b
		 * @return
		 */
		public function isSubclassOfSkyboy(a:Class, b:Class):Boolean
		{
			if (int(!a) | int(!b)) return false;
			return (a == b || a.prototype instanceof b);
		}
		
		/**
		 * 兼容性最高，支持几乎所有接口/类比较
		 * @param	a
		 * @param	b
		 * @return
		 */
		public function isSubclassOfJackson(a:Class, b:Class):Boolean
		{
			if (a == b)
			{
				return true;
			}
			var factoryNode:XMLList = XML(describeType(a)).factory;
			var superclassName:String = getQualifiedClassName(b);
			return factoryNode.extendsClass.@type.contains(superclassName)
					|| factoryNode.implementsInterface.@type.contains(superclassName);
		}
	}

}